import { Column, CreateDateColumn, Entity, PrimaryColumn, UpdateDateColumn } from "typeorm";
export enum SpiderTaskType {
    UNKNOWN = 0,
    SPIDER_KEYWORD_SEARCH_TOPIC_WEIBO = 1,
    SPIDER_KEYWORD_SEARCH_TOPIC_WEIBO_LIST = 2,
    SPIDER_KEYWORD_SEARCH_TOPIC_WEIBO_DETAIL = 3,
    SPIDER_KEYWORD_SEARCH_TOPIC_WEIBO_LIKE = 4,
    SPIDER_KEYWORD_SEARCH_TOPIC_WEIBO_COMMENT = 5,
    SPIDER_KEYWORD_SEARCH_TOPIC_WEIBO_SHARE = 6,
    SPIDER_KEYWORD_SEARCH_JD = 7,
    SPIDER_KEYWORD_SEARCH_JD_CATEGORY = 8,
    SPIDER_KEYWORD_SEARCH_JD_LIST = 9,
    SPIDER_KEYWORD_SEARCH_JD_DETAIL = 10,
}
export enum SpiderTaskStatus {
    UNKNOWN = 0,
    RUNING = 1,
    STOP = 2,
    WACHING = 4
}
/**
 * 爬虫任务库
 */
@Entity({
    name: 'spider_task'
})
export class SpiderTask {
    @PrimaryColumn()
    uuid: string;

    @Column({ default: 0, type: 'smallint', comment: '任务状态' })
    status: SpiderTaskStatus;

    @Column({ default: 0, type: 'smallint', comment: '任务类型' })
    type: SpiderTaskType;

    @Column({ type: 'jsonb', nullable: true, comment: '任务参数' })
    payload: any;

    @Column({ default: 0, type: 'bigint' })
    displayorder: number;

    @Column({ type: 'timestamp', default: 'NOW()' })
    sub_to_date: Date;

    @Column({ default: '' })
    key: string;

    @CreateDateColumn()
    create_date: Date;

    @UpdateDateColumn()
    update_date: Date;
}
export enum SpiderSubTaskStatus {
    UNKNOWN = 0,
    UNFINISH = 1,
    FINISH = 20,
}
@Entity({
    name: 'spider_sub_task'
})
export class SpiderSubTask {
    @PrimaryColumn()
    uuid: string;

    @Column()
    task_id: string;

    @Column({ default: 0, type: 'smallint', comment: '任务类型' })
    type: SpiderTaskType;

    @Column({ type: 'jsonb', nullable: true, comment: '任务参数' })
    payload: any;

    @Column({ default: SpiderSubTaskStatus.UNKNOWN, type: 'smallint', comment: '任务状态' })
    status: SpiderSubTaskStatus;

    @Column({ default: 0, type: 'bigint' })
    displayorder: number;

    @Column({ default: '' })
    parent_id: string;

    @CreateDateColumn()
    create_date: Date;

    @UpdateDateColumn()
    update_date: Date;
}

export enum SpiderLogType {
    UNKNOWN = 0,
    WEIBO_TOPIC = 1
}
@Entity({
    name: 'spider_log'
})
export class SpiderLog {
    @PrimaryColumn()
    uuid: string;

    @Column()
    log_id: string;

    @Column()
    author_id: string;

    @Column({ type: 'jsonb', nullable: true })
    detail: any;

    @Column({ default: SpiderLogType.UNKNOWN, type: 'smallint' })
    type: SpiderLogType;

    @Column({ default: 0, type: 'smallint' })
    status: number;

    @Column({ default: '' })
    task_id: string;

    @UpdateDateColumn()
    udpate_date: Date;

    @CreateDateColumn()
    create_date: Date;
}

export enum SpiderAuthorType {
    UNKNOWN = 0,
    WEIBO = 1,
}
@Entity({
    name: 'spider_author'
})
export class SpiderAuthor {
    @PrimaryColumn()
    uuid: string;

    @Column()
    author_id: string;

    @Column({ default: SpiderAuthorType.UNKNOWN, type: 'smallint' })
    type: SpiderAuthorType

    @Column({ type: 'jsonb', nullable: true })
    detail: any;

    @CreateDateColumn()
    create_date: Date;

    @UpdateDateColumn()
    udpate_date: Date;
}